#include "mutcamera.h"


D3DXMATRIX& CMUTCamera::GetMatrix(){
	Normalize();/*
	matView._11 = right.x;	matView._12 = up.x;	matView._13 = look.x;	matView._14 = 0;
	matView._21 = right.y;	matView._22 = up.y;	matView._23 = look.y;	matView._24 = 0;
	matView._31 = right.z;	matView._32 = up.z;	matView._33 = look.z;	matView._34 = 0;
	matView._41 = -D3DXVec3Dot( &pos, &right );	
	matView._42 = -D3DXVec3Dot( &pos, &up );	
	matView._43 = -D3DXVec3Dot( &pos, &look );	
	matView._44 = 1;*/
	D3DXMatrixLookAtLH( &matView, &(pos+lookAtPosBias*look), &(pos+look), &up );
	return matView;
}

void CMUTCamera::RotateUp( float rad ){
	D3DXMATRIX mat;
	D3DXMatrixRotationAxis( &mat, &up, rad );
	D3DXVec3TransformCoord( &look, &look, &mat );
	D3DXVec3Cross( &right, &up, &look );
	Normalize();
}

void CMUTCamera::RotateRight( float rad ){
	D3DXMATRIX mat;
	D3DXMatrixRotationAxis( &mat, &right, rad );
	D3DXVec3TransformCoord( &look, &look, &mat );
	if ( !bLockedUp )
		D3DXVec3Cross( &up, &look, &right );
	Normalize();
}